Repository navigation
cdc: reject malformed input and roll back recoverable failures - #148
Open
stevephodgson wants to merge 4 commits into
Open
stevephodgson wants to merge 4 commits into
stevephodgson wants to merge 4 commits into
Conversation
stevephodgson
marked this pull request as draft
September 4, 2026 10:06
Reject malformed CDC requests before they enter LogsDB or directory-lock handling. Keep request-specific validation beside each state machine while using a thin dispatcher at the network boundary. Account for the fixed CDC log-entry header when deciding whether client requests and shard responses fit a replication datagram. Replace oversized shard responses with MALFORMED_RESPONSE and avoid sending responses to a zero source port.
When a LogsDB response fails to unpack, remove the placeholder from the responses vector. Popping the requests vector instead can underflow it and leaves the malformed response in the batch.
Validate the CDC bootstrap flag and serialized request and response counts before resizing their vectors. Corrupt RocksDB values could otherwise create invalid bool representations or drive allocations from untrusted counts. Raise BincodeException on corruption so CDC startup or log application still stops rather than continuing with damaged TernFS metadata.
A STAT_DIRECTORY response can contain enough directory metadata to fit the shard transport but not a CDC LogsDB entry. The CDC replaces that response with MALFORMED_RESPONSE before replication. Release the edge locked by SoftUnlinkDirectory before returning that transport error to the client. Other decoded shard errors and response-shape violations remain internal invariants.
stevephodgson
force-pushed
the
cdc-input-hardening
branch
from
September 4, 2026 10:37
c1b7978 to
0c66169
Compare
stevephodgson
marked this pull request as ready for review
September 4, 2026 10:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Harden CDC request, response and persisted-log handling.
MALFORMED_RESPONSE.SoftUnlinkDirectorywhen an oversizedSTAT_DIRECTORYresponse cannot be replicated.This PR should be reviewed patch by patch.
Safety
Valid requests, responses that fit within the replication limit, and successful transactions follow the existing paths. There are no wire-format or storage-format changes.
Malformed client requests are rejected before entering LogsDB. Malformed LogsDB responses are dropped. Successfully decoded internal response contract violations remain assertions.
Corrupt persisted metadata still stops CDC processing through
BincodeException. The new checks stop before decoding an invalid boolean or allocating vectors from corrupt counts.The only new rollback path handles an oversized
STAT_DIRECTORYresponse duringSoftUnlinkDirectory. At that point the source edge has been locked but no irreversible operation has occurred, so CDC unlocks it before returningMALFORMED_RESPONSE.